<?php
if( empty( $_SESSION )){
	session_start();
}
header("Content-Type: text/html; charset=utf-8",true);

include_once("../models/cls.pagina.indice.php");
$oPaginaIndice = new pagina_indice();
$oPaginaIndice->load( $_POST );

if( empty( $_POST["id"] ) )
{
	$add = $oPaginaIndice->insert();
	if($add == 1)
	{
		?>
		<script>
			alert("REGISTRO ADICIONADO!");
			window.location.href="../views/frm.edicao.controle.php<?php echo "?id=".$_SESSION["id_edicao"]."&nome=".$_SESSION["nome_edicao"];?>";
		</script>
		<?php
	}
}
else{
	$add = $oPaginaIndice->update( $_POST["id"] );
	if($add == 1)
	{
		?>
		<script>
			alert("REGISTRO ALTERADO!");
			window.location.href="../views/frm.edicao.controle.php<?php echo "?id=".$_SESSION["id_edicao"]."&nome=".$_SESSION["nome_edicao"];?>";
		</script>
		<?php
	}
}
?>